function Resources(){

	var that = this
	this.publicdata;
	this.playername;
	 
	this.parseresults = function(data) {
		that.publicdata = data.public;
		that.playername = data.player.name;
		that.generatehtml()
	}
	
	this.generatePlayerData = function(player, color) {
		var htmldata = "";

		var name = player.name;
		if (name == that.playername)
			name = "You";
			
		htmldata += "<td><b><font color='"+color+"'>"+name+"</font></b></td>";
		
		if (player.phase == "Action")
			htmldata += "<td><span class='card_action' id='my_phase'>Action</span></td>"
		else if (player.phase == "Buy" || player.phase == "Payment")
			htmldata += "<td><span class='card_treasure' id='my_phase'>Buy</span></td>"
		else if (player.phase == "Sleep" || player.phase == "Output")
			htmldata += "<td><span class='card_unknown' id='my_phase'>Zzz..</span></td>"
		else if (player.phase == "Input" || player.phase == "BlackMarketPayment" || player.phase == "DigitalStorePayment")
			htmldata += "<td><span class='card_action_victory' id='my_phase'>Input</span></td>"
		else
			htmldata += "<td><span id='my_phase'></span></td>"
		
		
		
		if (player.phase == "Action")
			htmldata += "<td id='my_actions'><span class='card_action' >"+player.actions+"</span></td>";
		else
			htmldata += "<td id='my_actions'>"+player.actions+"</td>";
		
		if (player.phase == "Buy" || player.phase == "Payment")
			htmldata += "<td id='my_buys'><span class='card_treasure' >"+player.buys+"</span></td>";
		else
			htmldata += "<td id='my_buys'>"+player.buys+"</td>";
		
		
			
		htmldata += "<td id='my_coins'>"+player.coins+"$</td><td>"+player.potions+"&otimes;</td>"
		
		

		htmldata += "<td><div style='width:"+2 * player.playhandsize +"; height:15; background-color:999999;'></div><div style='text-align:right;'><font size='0'>"+player.playhandsize+"</font></div></td>";
		htmldata += "<td><div style='width:"+2 * player.playareasize +"; height:15; background-color:999999;'></div><div style='text-align:right;'><font size='0'>"+player.playareasize+"</font></div></td>";
		htmldata += "<td><div style='width:"+2 * player.drawdecksize +"; height:15; background-color:999999;'></div><div style='text-align:right;'><font size='0'>*</font></div></td>";
		htmldata += "<td><div style='width:"+2 * player.discarddecksize +"; height:15; background-color:999999;'></div><div style='text-align:right;'><font size='0'>"+player.discarddecksize+"</font></div></td>";
		
		if (that.publicdata.displaypirateshiptokens > 0)
			htmldata += "<td>"+player.pirateshiptokens+"</td>"
		
		if (that.publicdata.displaycointokens > 0)
			htmldata += "<td>"+player.cointokens+"</td>";
		
		if (that.publicdata.displayvictorytokens > 0)
			htmldata += "<td>"+player.victorytokens+"</td>";
			
		return htmldata;
	}
	 
	this.generatehtml = function() {
		var htmldata = "";
		
		htmldata += "<table border='1' rules='cols' frame='vsides' cellpadding='3'><tr align='center'>";
		htmldata += "<td><b>Player</b></td><td><b>Phase</b></td><td><b>Actions</b></b></td><td><b>Buys</b></td><td><b>Coins</b></td><td><b>Potions</b></td><td><b>Hand</b></td><td><b>Play</b></td><td><b>Deck</b></td><td><b>Discard</b></td>"
		
		if (that.publicdata.displaypirateshiptokens)
			htmldata += "<td><b>Pirateship Tokens</b></td>"
		
		if (that.publicdata.displaycointokens > 0)
			htmldata += "<td><b>Coin Tokens</b></td>";
			
		if (that.publicdata.displayvictorytokens > 0)
			htmldata += "<td><b>Victory Tokens</b></td>";

		var alen = that.publicdata.players.length;
		for ( var i=0, len=alen; i<len; ++i ){
			var color = "red";
			if (i == 0) {
				color = "green";
			}
			var op = that.publicdata.players[i];
			htmldata += "</tr><tr align='center'>";
			htmldata += that.generatePlayerData(op, color);
		}
		
		htmldata += "</tr></table>";
		var sec_resources = document.getElementById('sec_resources');
		sec_resources.innerHTML = htmldata;
	}
}

